package com.sun.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 用于补充springmvc的配置
 * 通常用于静态资源放行、拦截器、视图控制器等的功能配置
 * 使用注解@Configuration将其标记为一个配置类，在Springmvc核心容器中可通过扫描包加载到
 */
@Configuration
public class SpringMvcConfigSupport extends WebMvcConfigurationSupport {

    public SpringMvcConfigSupport(){
        System.out.println("过滤器启动...");
    }

    /**
     * 配置静态资源放行
     * 等同于在xml中配置<mvc:resources mapping="" location=""/>
     * @param registry
     */
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/css/**").addResourceLocations("/css/");
        registry.addResourceHandler("/static/**").addResourceLocations("/static/");
        registry.addResourceHandler("/js/**").addResourceLocations("/js/");
        registry.addResourceHandler("/pages/**").addResourceLocations("/pages/");
        registry.addResourceHandler("/plugins/**").addResourceLocations("/plugins/");
    }

}